import React from 'react'
import axios from 'axios'

const Order: React.FC = () => {
  const orderID = new Date().getTime()
  const address = '上海八维宏烨校区';
  const tel = '15565543645';
  const user = '大黑耗子';
  const price = 100;
  const title = '手机消费';

  const submit = async () => {
    const res = await axios.post('/api/order/pay',{
      orderID,
      address,
      tel,
      user,
      price,
      title,
    })
    window.location.href = res.data.data;
    
  }
  
  return (
    <div>
      <div>
      <div>
        <span>订单id: {orderID}</span>
      </div>
      <div>
        <span>订单地址：{address}</span>
      </div>
      <div>
        <span>联系方式：{tel}</span>
      </div>
      <div>
        <span>用户: {user}</span>
      </div>
      <div>
        <span>金额: {price}</span>
      </div>
      <div>
        <span>title: {title}</span>
      </div>
      <button onClick={submit}>立即支付</button>
    </div>
    </div>
  )
}

export default Order